package org.example.seata.bs.auth.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.example.seata.bs.auth.handler.code.SendCodeHandlerChain;
import org.example.seata.common.core.util.ApiResp;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author hzq
 * @date 2021/12/23 13:10
 */
@Api(tags = "发送验证码")
@RestController
@RequestMapping("/sendCode")
@AllArgsConstructor
public class SendCodeController {

    private final SendCodeHandlerChain sendCodeHandlerChain;

    @GetMapping("/login")
    @ApiOperation("发送登录验证码")
    public ApiResp<Object> login(@ApiParam(name = "principal", value = "发送目标") @RequestParam String principal,
                                 @ApiParam(name = "handlerType", value = "发送类型") @RequestParam String handlerType) {
        return sendCodeHandlerChain.sendCode(principal, handlerType);
    }
}
